﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TCHSHue.DAL;
using TCHSHue.BLL;
namespace TCHSHue.Modules.AdminControl.DangNhap
{
    public partial class ctrDangNhap : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var user = (DAL.User)Session["userDangNhap"];
            if (user != null)
            {
                //string returnUrl = Request.QueryString["returnUrl"];
                //if (!string.IsNullOrEmpty(returnUrl))
                //{
                //    returnUrl = returnUrl.Replace("*", "&");
                //    Response.Redirect(returnUrl);
                //}
                //else
                Response.Redirect("~/Modules/Admin.aspx");
            }
        }

        protected void bntDangNhap_Click(object sender, EventArgs e)
        {
            var user = UserBLL.getUser(txtTenDangNhap.Text.Trim(), txtMatKhau.Text.Trim());
            if (user != null)
            {
                Session["userDangNhap"] = user;
                //string returnUrl = Request.QueryString["returnUrl"];
                //if (!string.IsNullOrEmpty(returnUrl))
                //{
                //    returnUrl = returnUrl.Replace("*", "&");
                //    Response.Redirect(returnUrl);
                //}
                //else
                Response.Redirect("~/Modules/Admin.aspx");
            }
            else
                loiDangNhap.Visible = true;
        }
    }
}